﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CardGamesLibrary.Cards;
using CardGamesLibrary.Cards.Decks;
using CardGamesLibrary.Tables;

namespace CardGamesLibrary.Poker
{
    public class PokerTable : GameTable<FrenchDeckCard>
    {
        public int CurrentPot { get; set; }

        public ICardSet<FrenchDeckCard> Cards { get; set; }

        public int BigBlind { get; private set; }
        public int SmallBlind { get; private set; }

        public PokerTable(int playerSeats) : base(playerSeats)
        {
            Cards = new Hand<FrenchDeckCard>();
            SmallBlind = 5;
            BigBlind = SmallBlind*2;
        }

        public void AddPlayer(PokerPlayer player, int buyIn)
        {
          if (player.Chips <= buyIn) return;

            player.Chips -= buyIn;
            var newSeat = AddPlayer(player) as PokerSeat;
            
            if (newSeat != null) 
                newSeat.Chips = buyIn;
        }

        public override TableSeat AddPlayer(Player player)
        {
         
            var tableSeat = Seats.Find(a => a.Player == null);
            tableSeat.Player = player;
            return tableSeat;
        }


        public override TableSeat CreateNewSeat()
        {
            return new PokerSeat(this);
        }

        public override Cards.Decks.Deck<FrenchDeckCard> CreateDeck()
        {
           return new FrenchDeck();
        }
    }
}
